

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="Description" content="scikit-learn: machine learning in Python">

  
  <title>Installing scikit-learn &mdash; scikit-learn 0.22 documentation</title>
  
  <link rel="canonical" href="http://scikit-learn.org/stable/install.html" />

  
  <link rel="shortcut icon" href="_static/favicon.ico"/>
  

  <link rel="stylesheet" href="_static/css/vendor/bootstrap.min.css" type="text/css" />
  <link rel="stylesheet" href="_static/gallery.css" type="text/css" />
  <link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script> 
</head>
<body>
<nav id="navbar" class="sk-docs-navbar navbar navbar-expand-md navbar-light bg-light py-0">
  <div class="container-fluid sk-docs-container px-0">
      <a class="navbar-brand py-0" href="index.html">
        <img
          class="sk-brand-img"
          src="_static/scikit-learn-logo-small.png"
          alt="logo"/>
      </a>
    <button
      id="sk-navbar-toggler"
      class="navbar-toggler"
      type="button"
      data-toggle="collapse"
      data-target="#navbarSupportedContent"
      aria-controls="navbarSupportedContent"
      aria-expanded="false"
      aria-label="Toggle navigation"
    >
      <span class="navbar-toggler-icon"></span>
    </button>

    <div class="sk-navbar-collapse collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav mr-auto">
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="#">Install</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="user_guide.html">User Guide</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="modules/classes.html">API</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link" href="auto_examples/index.html">Examples</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="getting_started.html">Getting Started</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="tutorial/index.html">Tutorial</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="glossary.html">Glossary</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="developers/index.html">Development</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="faq.html">FAQ</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="related_projects.html">Related packages</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="roadmap.html">Roadmap</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="about.html">About us</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="https://github.com/scikit-learn/scikit-learn">GitHub</a>
        </li>
        <li class="nav-item">
          <a class="sk-nav-link nav-link nav-more-item-mobile-items" href="https://scikit-learn.org/dev/versions.html">Other Versions</a>
        </li>
        <li class="nav-item dropdown nav-more-item-dropdown">
          <a class="sk-nav-link nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">More</a>
          <div class="dropdown-menu" aria-labelledby="navbarDropdown">
              <a class="sk-nav-dropdown-item dropdown-item" href="getting_started.html">Getting Started</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="tutorial/index.html">Tutorial</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="glossary.html">Glossary</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="developers/index.html">Development</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="faq.html">FAQ</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="related_projects.html">Related packages</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="roadmap.html">Roadmap</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="about.html">About us</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="https://github.com/scikit-learn/scikit-learn">GitHub</a>
              <a class="sk-nav-dropdown-item dropdown-item" href="https://scikit-learn.org/dev/versions.html">Other Versions</a>
          </div>
        </li>
      </ul>
      <div id="searchbox" role="search">
          <div class="searchformwrapper">
          <form class="search" action="search.html" method="get">
            <input class="sk-search-text-input" type="text" name="q" aria-labelledby="searchlabel" />
            <input class="sk-search-text-btn" type="submit" value="Go" />
          </form>
          </div>
      </div>
    </div>
  </div>
</nav>
<div class="d-flex" id="sk-doc-wrapper">
    <input type="checkbox" name="sk-toggle-checkbox" id="sk-toggle-checkbox">
    <label id="sk-sidemenu-toggle" class="sk-btn-toggle-toc btn sk-btn-primary" for="sk-toggle-checkbox">Toggle Menu</label>
    <div id="sk-sidebar-wrapper" class="border-right">
      <div class="sk-sidebar-toc-wrapper">
        <div class="sk-sidebar-toc-logo">
          <a href="index.html">
            <img
              class="sk-brand-img"
              src="_static/scikit-learn-logo-small.png"
              alt="logo"/>
          </a>
        </div>
        <div class="btn-group w-100 mb-2" role="group" aria-label="rellinks">
            <a href="preface.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="Welcome to scikit-learn">Prev</a><a href="preface.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="Welcome to scikit-learn">Up</a>
            <a href="faq.html" role="button" class="btn sk-btn-rellink py-1" sk-rellink-tooltip="Frequently Asked Questions">Next</a>
        </div>
        <div class="alert alert-warning p-1 mb-2" role="alert">
          <p class="text-center mb-0">
            Please <a class="font-weight-bold" href="about.html#citing-scikit-learn"><string>cite us</string></a> if you use the software.
          </p>
        </div>
          <div class="sk-sidebar-toc">
            <ul>
<li><a class="reference internal" href="#">Installing scikit-learn</a><ul>
<li><a class="reference internal" href="#installing-the-latest-release">Installing the latest release</a></li>
<li><a class="reference internal" href="#third-party-distributions-of-scikit-learn">Third party distributions of scikit-learn</a><ul>
<li><a class="reference internal" href="#arch-linux">Arch Linux</a></li>
<li><a class="reference internal" href="#debian-ubuntu">Debian/Ubuntu</a></li>
<li><a class="reference internal" href="#fedora">Fedora</a></li>
<li><a class="reference internal" href="#netbsd">NetBSD</a></li>
<li><a class="reference internal" href="#macports-for-mac-osx">MacPorts for Mac OSX</a></li>
<li><a class="reference internal" href="#canopy-and-anaconda-for-all-supported-platforms">Canopy and Anaconda for all supported platforms</a></li>
<li><a class="reference internal" href="#intel-conda-channel">Intel conda channel</a></li>
<li><a class="reference internal" href="#winpython-for-windows">WinPython for Windows</a></li>
</ul>
</li>
</ul>
</li>
</ul>

          </div>
      </div>
    </div>
    <div id="sk-page-content-wrapper">
      <div class="sk-page-content container-fluid body px-md-3" role="main">
        
  <div class="section" id="installing-scikit-learn">
<span id="installation-instructions"></span><h1>Installing scikit-learn<a class="headerlink" href="#installing-scikit-learn" title="Permalink to this headline">¶</a></h1>
<p>There are different ways to install scikit-learn:</p>
<blockquote>
<div><ul class="simple">
<li><p><a class="reference internal" href="#install-official-release"><span class="std std-ref">Install the latest official release</span></a>. This
is the best approach for most users. It will provide a stable version
and pre-built packages are available for most platforms.</p></li>
<li><p>Install the version of scikit-learn provided by your
<a class="reference internal" href="#install-by-distribution"><span class="std std-ref">operating system or Python distribution</span></a>.
This is a quick option for those who have operating systems or Python
distributions that distribute scikit-learn.
It might not provide the latest release version.</p></li>
<li><p><a class="reference internal" href="developers/advanced_installation.html#install-bleeding-edge"><span class="std std-ref">Building the package from source</span></a>. This is best for users who want the
latest-and-greatest features and aren’t afraid of running
brand-new code. This is also needed for users who wish to contribute to the
project.</p></li>
</ul>
</div></blockquote>
<div class="section" id="installing-the-latest-release">
<span id="install-official-release"></span><h2>Installing the latest release<a class="headerlink" href="#installing-the-latest-release" title="Permalink to this headline">¶</a></h2>
<div class="install">
     <strong>Operating System</strong>
        <input type="radio" name="os" id="quickstart-win" checked>
        <label for="quickstart-win">Windows</label>
        <input type="radio" name="os" id="quickstart-mac">
        <label for="quickstart-mac">macOS</label>
        <input type="radio" name="os" id="quickstart-lin">
        <label for="quickstart-lin">Linux</label><br />
     <strong>Packager</strong>
        <input type="radio" name="packager" id="quickstart-pip" checked>
        <label for="quickstart-pip">pip</label>
        <input type="radio" name="packager" id="quickstart-conda">
        <label for="quickstart-conda">conda</label><br />
        <input type="checkbox" name="config" id="quickstart-venv">
        <label for="quickstart-venv"></label>
     </span><div>
  <span class="sk-expandable" data-packager="pip" data-os="windows">Install the 64bit version of Python 3, for instance from <a href="https://www.python.org/">https://www.python.org</a>.</span
  ><span class="sk-expandable" data-packager="pip" data-os="mac">Install Python 3 using <a href="https://brew.sh/">homebrew</a> (<code>brew install python</code>) or by manually installing the package from <a href="https://www.python.org">https://www.python.org</a>.</span
  ><span class="sk-expandable" data-packager="pip" data-os="linux">Install python3 and python3-pip using the package manager of the Linux Distribution.</span
  ><span class="sk-expandable" data-packager="conda"><a href="https://docs.conda.io/projects/conda/en/latest/user-guide/install/">Install conda</a> (no administrator permission required).</span>
</div><p>Then run:</p>
<div class="highlight"><pre><code
 ><span class="sk-expandable" data-packager="pip" data-os="linux" data-venv="">python3 -m venv sklearn-venv</span
 ><span class="sk-expandable" data-packager="pip" data-os="windows" data-venv="">python -m venv sklearn-venv</span
 ><span class="sk-expandable" data-packager="pip" data-os="mac" data-venv="">python -m venv sklearn-venv</span
 ><span class="sk-expandable" data-packager="pip" data-os="linux" data-venv="">source sklearn-venv/bin/activate</span
 ><span class="sk-expandable" data-packager="pip" data-os="mac" data-venv="">source sklearn-venv/bin/activate</span
 ><span class="sk-expandable" data-packager="pip" data-os="windows" data-venv="">sklearn-venv\Scripts\activate</span
 ><span class="sk-expandable" data-packager="pip" data-venv="">pip install -U scikit-learn</span
 ><span class="sk-expandable" data-packager="pip" data-os="mac" data-venv="no">pip install -U scikit-learn</span
 ><span class="sk-expandable" data-packager="pip" data-os="windows" data-venv="no">pip install -U scikit-learn</span
 ><span class="sk-expandable" data-packager="pip" data-os="linux" data-venv="no">pip3 install -U scikit-learn</span
 ><span class="sk-expandable" data-packager="conda" data-venv="">conda create -n sklearn-env</span
 ><span class="sk-expandable" data-packager="conda" data-venv="">conda activate sklearn-env</span
 ><span class="sk-expandable" data-packager="conda">conda install scikit-learn </span
></code></pre></div><p>In order to check your installation you can use</p>
 <div class="highlight"><pre><code
    ><span class="sk-expandable" data-packager="pip" data-os="linux" data-venv="no">python3 -m pip show scikit-learn  # to see which version and where scikit-learn is installed</span
    ><span class="sk-expandable" data-packager="pip" data-os="linux" data-venv="no">python3 -m pip freeze  # to see all packages installed in the active virtualenv</span
    ><span class="sk-expandable" data-packager="pip" data-os="linux" data-venv="no">python3 -c "import sklearn; sklearn.show_versions()"</span
    ><span class="sk-expandable" data-packager="pip" data-venv="">python -m pip show scikit-learn  # to see which version and where scikit-learn is installed</span
    ><span class="sk-expandable" data-packager="pip" data-venv="">python -m pip freeze  # to see all packages installed in the active virtualenv</span
    ><span class="sk-expandable" data-packager="pip" data-venv="">python -c "import sklearn; sklearn.show_versions()"</span
    ><span class="sk-expandable" data-packager="pip" data-os="windows" data-venv="no">python -m pip show scikit-learn  # to see which version and where scikit-learn is installed</span
    ><span class="sk-expandable" data-packager="pip" data-os="windows" data-venv="no">python -m pip freeze  # to see all packages installed in the active virtualenv</span
    ><span class="sk-expandable" data-packager="pip" data-os="windows" data-venv="no">python -c "import sklearn; sklearn.show_versions()"</span
    ><span class="sk-expandable" data-packager="pip" data-os="mac" data-venv="no">python -m pip show scikit-learn  # to see which version and where scikit-learn is installed</span
    ><span class="sk-expandable" data-packager="pip" data-os="mac" data-venv="no">python -m pip freeze  # to see all packages installed in the active virtualenv</span
    ><span class="sk-expandable" data-packager="pip" data-os="mac" data-venv="no">python -c "import sklearn; sklearn.show_versions()"</span
    ><span class="sk-expandable" data-packager="conda">conda list scikit-learn  # to see which scikit-learn version is installed</span
    ><span class="sk-expandable" data-packager="conda">conda list  # to see all packages installed in the active conda environment</span
    ><span class="sk-expandable" data-packager="conda">python -c "import sklearn; sklearn.show_versions()"</span
    ></code></pre></div>
</div><p>Note that in order to avoid potential conflicts with other packages it is
strongly recommended to use a virtual environment, e.g. python3 <code class="docutils literal notranslate"><span class="pre">virtualenv</span></code>
(see <a class="reference external" href="https://docs.python.org/3/tutorial/venv.html">python3 virtualenv documentation</a>) or <a class="reference external" href="https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html">conda environments</a>.</p>
<p>Using an isolated environment makes possible to install a specific version of
scikit-learn and its dependencies independently of any previously installed
Python packages.
In particular under Linux is it discouraged to install pip packages alongside
the packages managed by the package manager of the distribution
(apt, dnf, pacman…).</p>
<p>Note that you should always remember to activate the environment of your choice
prior to running any Python command whenever you start a new terminal session.</p>
<p>If you have not installed NumPy or SciPy yet, you can also install these using
conda or pip. When using pip, please ensure that <em>binary wheels</em> are used,
and NumPy and SciPy are not recompiled from source, which can happen when using
particular configurations of operating system and hardware (such as Linux on
a Raspberry Pi).</p>
<p>If you must install scikit-learn and its dependencies with pip, you can install
it as <code class="docutils literal notranslate"><span class="pre">scikit-learn[alldeps]</span></code>.</p>
<p>Scikit-learn plotting capabilities (i.e., functions start with “plot_”
and classes end with “Display”) require Matplotlib (&gt;= 1.5.1). For running the
examples Matplotlib &gt;= 1.5.1 is required. A few examples require
scikit-image &gt;= 0.12.3, a few examples require pandas &gt;= 0.18.0.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Scikit-learn 0.20 was the last version to support Python 2.7 and Python 3.4.
Scikit-learn now requires Python 3.5 or newer.</p>
</div>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>For installing on PyPy, PyPy3-v5.10+, Numpy 1.14.0+, and scipy 1.1.0+
are required.</p>
</div>
</div>
<div class="section" id="third-party-distributions-of-scikit-learn">
<span id="install-by-distribution"></span><h2>Third party distributions of scikit-learn<a class="headerlink" href="#third-party-distributions-of-scikit-learn" title="Permalink to this headline">¶</a></h2>
<p>Some third-party distributions provide versions of
scikit-learn integrated with their package-management systems.</p>
<p>These can make installation and upgrading much easier for users since
the integration includes the ability to automatically install
dependencies (numpy, scipy) that scikit-learn requires.</p>
<p>The following is an incomplete list of OS and python distributions
that provide their own version of scikit-learn.</p>
<div class="section" id="arch-linux">
<h3>Arch Linux<a class="headerlink" href="#arch-linux" title="Permalink to this headline">¶</a></h3>
<p>Arch Linux’s package is provided through the <a class="reference external" href="https://www.archlinux.org/packages/?q=scikit-learn">official repositories</a> as
<code class="docutils literal notranslate"><span class="pre">python-scikit-learn</span></code> for Python.
It can be installed by typing the following command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>$ sudo pacman -S python-scikit-learn
</pre></div>
</div>
</div>
<div class="section" id="debian-ubuntu">
<h3>Debian/Ubuntu<a class="headerlink" href="#debian-ubuntu" title="Permalink to this headline">¶</a></h3>
<p>The Debian/Ubuntu package is splitted in three different packages called
<code class="docutils literal notranslate"><span class="pre">python3-sklearn</span></code> (python modules), <code class="docutils literal notranslate"><span class="pre">python3-sklearn-lib</span></code> (low-level
implementations and bindings), <code class="docutils literal notranslate"><span class="pre">python3-sklearn-doc</span></code> (documentation).
Only the Python 3 version is available in the Debian Buster (the more recent
Debian distribution).
Packages can be installed using <code class="docutils literal notranslate"><span class="pre">apt-get</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo apt-get install python3-sklearn python3-sklearn-lib python3-sklearn-doc
</pre></div>
</div>
</div>
<div class="section" id="fedora">
<h3>Fedora<a class="headerlink" href="#fedora" title="Permalink to this headline">¶</a></h3>
<p>The Fedora package is called <code class="docutils literal notranslate"><span class="pre">python3-scikit-learn</span></code> for the python 3 version,
the only one available in Fedora30.
It can be installed using <code class="docutils literal notranslate"><span class="pre">dnf</span></code>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo dnf install python3-scikit-learn
</pre></div>
</div>
</div>
<div class="section" id="netbsd">
<h3>NetBSD<a class="headerlink" href="#netbsd" title="Permalink to this headline">¶</a></h3>
<p>scikit-learn is available via <a class="reference external" href="http://pkgsrc-wip.sourceforge.net/">pkgsrc-wip</a>:</p>
<blockquote>
<div><p><a class="reference external" href="http://pkgsrc.se/math/py-scikit-learn">http://pkgsrc.se/math/py-scikit-learn</a></p>
</div></blockquote>
</div>
<div class="section" id="macports-for-mac-osx">
<h3>MacPorts for Mac OSX<a class="headerlink" href="#macports-for-mac-osx" title="Permalink to this headline">¶</a></h3>
<p>The MacPorts package is named <code class="docutils literal notranslate"><span class="pre">py&lt;XY&gt;-scikits-learn</span></code>,
where <code class="docutils literal notranslate"><span class="pre">XY</span></code> denotes the Python version.
It can be installed by typing the following
command:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ sudo port install py36-scikit-learn
</pre></div>
</div>
</div>
<div class="section" id="canopy-and-anaconda-for-all-supported-platforms">
<h3>Canopy and Anaconda for all supported platforms<a class="headerlink" href="#canopy-and-anaconda-for-all-supported-platforms" title="Permalink to this headline">¶</a></h3>
<p><a class="reference external" href="https://www.enthought.com/products/canopy">Canopy</a> and <a class="reference external" href="https://www.anaconda.com/download">Anaconda</a> both ship a recent
version of scikit-learn, in addition to a large set of scientific python
library for Windows, Mac OSX and Linux.</p>
<p>Anaconda offers scikit-learn as part of its free distribution.</p>
</div>
<div class="section" id="intel-conda-channel">
<h3>Intel conda channel<a class="headerlink" href="#intel-conda-channel" title="Permalink to this headline">¶</a></h3>
<p>Intel maintains a dedicated conda channel that ships scikit-learn:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span>$ conda install -c intel scikit-learn
</pre></div>
</div>
<p>This version of scikit-learn comes with alternative solvers for some common
estimators. Those solvers come from the DAAL C++ library and are optimized for
multi-core Intel CPUs.</p>
<p>Note that those solvers are not enabled by default, please refer to the
<a class="reference external" href="https://intelpython.github.io/daal4py/sklearn.html">daal4py</a> documentation
for more details.</p>
<p>Compatibility with the standard scikit-learn solvers is checked by running the
full scikit-learn test suite via automated continuous integration as reported
on <a class="reference external" href="https://github.com/IntelPython/daal4py">https://github.com/IntelPython/daal4py</a>.</p>
</div>
<div class="section" id="winpython-for-windows">
<h3>WinPython for Windows<a class="headerlink" href="#winpython-for-windows" title="Permalink to this headline">¶</a></h3>
<p>The <a class="reference external" href="https://winpython.github.io/">WinPython</a> project distributes
scikit-learn as an additional plugin.</p>
</div>
</div>
</div>


      </div>
    <div class="container">
      <footer class="sk-content-footer">
            &copy; 2007 - 2019, scikit-learn developers (BSD License).
          <a href="_sources/install.rst.txt" rel="nofollow">Show this page source</a>
      </footer>
    </div>
  </div>
</div>
<script src="_static/js/vendor/bootstrap.min.js"></script>

<script>
    window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
    ga('create', 'UA-22606712-2', 'auto');
    ga('set', 'anonymizeIp', true);
    ga('send', 'pageview');
</script>
<script async src='https://www.google-analytics.com/analytics.js'></script>


<script>
$(document).ready(function() {
    /* Add a [>>>] button on the top-right corner of code samples to hide
     * the >>> and ... prompts and the output and thus make the code
     * copyable. */
    var div = $('.highlight-python .highlight,' +
                '.highlight-python3 .highlight,' +
                '.highlight-pycon .highlight,' +
		'.highlight-default .highlight')
    var pre = div.find('pre');

    // get the styles from the current theme
    pre.parent().parent().css('position', 'relative');
    var hide_text = 'Hide prompts and outputs';
    var show_text = 'Show prompts and outputs';

    // create and add the button to all the code blocks that contain >>>
    div.each(function(index) {
        var jthis = $(this);
        if (jthis.find('.gp').length > 0) {
            var button = $('<span class="copybutton">&gt;&gt;&gt;</span>');
            button.attr('title', hide_text);
            button.data('hidden', 'false');
            jthis.prepend(button);
        }
        // tracebacks (.gt) contain bare text elements that need to be
        // wrapped in a span to work with .nextUntil() (see later)
        jthis.find('pre:has(.gt)').contents().filter(function() {
            return ((this.nodeType == 3) && (this.data.trim().length > 0));
        }).wrap('<span>');
    });

    // define the behavior of the button when it's clicked
    $('.copybutton').click(function(e){
        e.preventDefault();
        var button = $(this);
        if (button.data('hidden') === 'false') {
            // hide the code output
            button.parent().find('.go, .gp, .gt').hide();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'hidden');
            button.css('text-decoration', 'line-through');
            button.attr('title', show_text);
            button.data('hidden', 'true');
        } else {
            // show the code output
            button.parent().find('.go, .gp, .gt').show();
            button.next('pre').find('.gt').nextUntil('.gp, .go').css('visibility', 'visible');
            button.css('text-decoration', 'none');
            button.attr('title', hide_text);
            button.data('hidden', 'false');
        }
    });

	/*** Add permalink buttons next to glossary terms ***/
	$('dl.glossary > dt[id]').append(function() {
		return ('<a class="headerlink" href="#' +
			    this.getAttribute('id') +
			    '" title="Permalink to this term">¶</a>');
	});
  /*** Hide navbar when scrolling down ***/
  // Returns true when headerlink target matches hash in url
  (function() {
    hashTargetOnTop = function() {
        var hash = window.location.hash;
        if ( hash.length < 2 ) { return false; }

        var target = document.getElementById( hash.slice(1) );
        if ( target === null ) { return false; }

        var top = target.getBoundingClientRect().top;
        return (top < 2) && (top > -2);
    };

    // Hide navbar on load if hash target is on top
    var navBar = document.getElementById("navbar");
    var navBarToggler = document.getElementById("sk-navbar-toggler");
    var navBarHeightHidden = "-" + navBar.getBoundingClientRect().height + "px";
    var $window = $(window);

    hideNavBar = function() {
        navBar.style.top = navBarHeightHidden;
    };

    showNavBar = function() {
        navBar.style.top = "0";
    }

    if (hashTargetOnTop()) {
        hideNavBar()
    }

    var prevScrollpos = window.pageYOffset;
    hideOnScroll = function(lastScrollTop) {
        if (($window.width() < 768) && (navBarToggler.getAttribute("aria-expanded") === 'true')) {
            return;
        }
        if (lastScrollTop > 2 && (prevScrollpos <= lastScrollTop) || hashTargetOnTop()){
            hideNavBar()
        } else {
            showNavBar()
        }
        prevScrollpos = lastScrollTop;
    };

    /*** high preformance scroll event listener***/
    var raf = window.requestAnimationFrame ||
        window.webkitRequestAnimationFrame ||
        window.mozRequestAnimationFrame ||
        window.msRequestAnimationFrame ||
        window.oRequestAnimationFrame;
    var lastScrollTop = $window.scrollTop();

    if (raf) {
        loop();
    }

    function loop() {
        var scrollTop = $window.scrollTop();
        if (lastScrollTop === scrollTop) {
            raf(loop);
            return;
        } else {
            lastScrollTop = scrollTop;
            hideOnScroll(lastScrollTop);
            raf(loop);
        }
    }
  })();
});

</script>
    
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js"></script>
    
</body>
</html>